﻿{extend name="public:public" /}
{block name="section"}
<section class="Hui-article-box">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span> 评论管理
		<span class="c-gray en">&gt;</span> 评论列表
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="r">共有数据：<strong>{:count($list)}</strong> 条</span> </div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-hover table-bg table-sort">
					<thead>
						<tr class="text-c">
							<th width="80">ID</th>
							<th width="100">评论内容</th>
							<th width="100">回复信息</th>
							<th width="100">状态</th>
							<th width="100">操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="list" id="vo"}
						<tr class="text-c">
							<td>{$vo.id}</td>
							<td>{$vo.content}</td>
							<td>{$vo.reply}</td>
							<td class="td-status">
								{if condition = '$vo.state eq 1'}
									<span class="label label-success radius">已启用</span>
								{else}
									<span class="label label-defaunt radius">已停用</span>
								{/if}
							</td>
							<td class="td-manage">
								{if condition = '$vo.state eq 1'}
									<a style="text-decoration:none" onClick="member_stop(this,'{$vo.id}')" href="javascript:;" title="停用">
										<i class="Hui-iconfont">&#xe631;</i>
									</a>
								{else}
									<a style="text-decoration:none" onClick="member_start(this,'{$vo.id}')" href="javascript:;" title="启用">
										<i class="Hui-iconfont">&#xe6e1;</i>
									</a>
								{/if}
								<a title="回复" href="javascript:;" onclick="member_edit('回复','reply','{$vo.id}','','510')" class="ml-5" style="text-decoration:none">
									<i class="Hui-iconfont">&#xe68a;</i>
								</a>
								<a title="删除" href="javascript:;" onclick="member_del(this,'{$vo.id}')" class="ml-5" style="text-decoration:none">
									<i class="Hui-iconfont">&#xe6e2;</i>
								</a>
							</td>
						</tr>
						{/volist}
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>
<script type="text/javascript">

    $('#menu-comment').children('dt').addClass('selected');
    $('#menu-comment').children('dd').show();
    $('#menu-comment').children('dd').find('a').eq(0).css({
        color:'#148cf1',
        backgroundColor:'#FFF'
    });


$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [[ 0, "asc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[-1]}// 制定列不参与排序
		]
	});

});

/*用户-停用*/
function member_stop(obj,id){
	layer.confirm('确认要停用吗？',function(index){
        $.ajax({
            type: 'POST',
            url: 'change',
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                layer.msg(data.msg,{icon:1,time:1000},function () {
                    if(data.status == 1){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_start(this,'+id+')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
                        $(obj).remove();
                    }
                });

            },
            error:function(data) {
                layer.msg('服务器错误',{icon:2,time:1000});
            },
        });


	});
}

/*用户-启用*/
function member_start(obj,id){
	layer.confirm('确认要启用吗？',function(index){
        $.ajax({
            type: 'POST',
            url: 'change',
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                layer.msg(data.msg,{icon:1,time:1000},function () {
                    if(data.status == 1){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,'+id+')" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                        $(obj).remove();
                    }
                });

            },
            error:function(data) {
                layer.msg('服务器错误',{icon:2,time:1000});
            },
        });

	});
}

/*用户-编辑*/
function member_edit(title,url,id,w,h){
	layer_show(title,url+'/id/'+id,w,h);
}
function member_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: 'del',
			data:{'id':id},
			dataType: 'json',
			success: function(data){
				layer.msg(data.msg,{icon:data.icon,time:1000},function () {
					if(data.status == 1){
						$(obj).parents("tr").remove();
					}
				});

			},
			error:function(data) {
                layer.msg('服务器错误',{icon:2,time:1000});
			},
		});
	});
}
</script>
{/block}

